using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex{
    /// <summary>
    /// Strongly-typed collection for the VProgram class.
    /// </summary>
    [Serializable]
    public partial class VProgramCollection : ReadOnlyList<VProgram, VProgramCollection>
    {        
        public VProgramCollection() {}

    }

    /// <summary>
    /// This is  Read-only wrapper class for the vProgram view.
    /// </summary>
    [Serializable]
    public partial class VProgram : ReadOnlyRecord<VProgram> 
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }

	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }

                return BaseSchema;
            }

        }

    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vProgram", TableType.View, DataService.GetInstance("Adex"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = "dbo";
                //columns
                
                TableSchema.TableColumn colvarProgramID = new TableSchema.TableColumn(schema);
                colvarProgramID.ColumnName = "ProgramID";
                colvarProgramID.DataType = DbType.Int32;
                colvarProgramID.MaxLength = 0;
                colvarProgramID.AutoIncrement = false;
                colvarProgramID.IsNullable = false;
                colvarProgramID.IsPrimaryKey = false;
                colvarProgramID.IsForeignKey = false;
                colvarProgramID.IsReadOnly = false;
                
                schema.Columns.Add(colvarProgramID);
                
                TableSchema.TableColumn colvarProgramCode = new TableSchema.TableColumn(schema);
                colvarProgramCode.ColumnName = "ProgramCode";
                colvarProgramCode.DataType = DbType.Int32;
                colvarProgramCode.MaxLength = 0;
                colvarProgramCode.AutoIncrement = false;
                colvarProgramCode.IsNullable = false;
                colvarProgramCode.IsPrimaryKey = false;
                colvarProgramCode.IsForeignKey = false;
                colvarProgramCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarProgramCode);
                
                TableSchema.TableColumn colvarProgramName = new TableSchema.TableColumn(schema);
                colvarProgramName.ColumnName = "ProgramName";
                colvarProgramName.DataType = DbType.String;
                colvarProgramName.MaxLength = 255;
                colvarProgramName.AutoIncrement = false;
                colvarProgramName.IsNullable = true;
                colvarProgramName.IsPrimaryKey = false;
                colvarProgramName.IsForeignKey = false;
                colvarProgramName.IsReadOnly = false;
                
                schema.Columns.Add(colvarProgramName);
                
                TableSchema.TableColumn colvarMediaCode = new TableSchema.TableColumn(schema);
                colvarMediaCode.ColumnName = "MediaCode";
                colvarMediaCode.DataType = DbType.Int32;
                colvarMediaCode.MaxLength = 0;
                colvarMediaCode.AutoIncrement = false;
                colvarMediaCode.IsNullable = true;
                colvarMediaCode.IsPrimaryKey = false;
                colvarMediaCode.IsForeignKey = false;
                colvarMediaCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarMediaCode);
                
                TableSchema.TableColumn colvarDateAdded = new TableSchema.TableColumn(schema);
                colvarDateAdded.ColumnName = "DateAdded";
                colvarDateAdded.DataType = DbType.DateTime;
                colvarDateAdded.MaxLength = 0;
                colvarDateAdded.AutoIncrement = false;
                colvarDateAdded.IsNullable = false;
                colvarDateAdded.IsPrimaryKey = false;
                colvarDateAdded.IsForeignKey = false;
                colvarDateAdded.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAdded);
                
                TableSchema.TableColumn colvarDateModified = new TableSchema.TableColumn(schema);
                colvarDateModified.ColumnName = "DateModified";
                colvarDateModified.DataType = DbType.DateTime;
                colvarDateModified.MaxLength = 0;
                colvarDateModified.AutoIncrement = false;
                colvarDateModified.IsNullable = false;
                colvarDateModified.IsPrimaryKey = false;
                colvarDateModified.IsForeignKey = false;
                colvarDateModified.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateModified);
                
                TableSchema.TableColumn colvarMediaName = new TableSchema.TableColumn(schema);
                colvarMediaName.ColumnName = "MediaName";
                colvarMediaName.DataType = DbType.String;
                colvarMediaName.MaxLength = 255;
                colvarMediaName.AutoIncrement = false;
                colvarMediaName.IsNullable = true;
                colvarMediaName.IsPrimaryKey = false;
                colvarMediaName.IsForeignKey = false;
                colvarMediaName.IsReadOnly = false;
                
                schema.Columns.Add(colvarMediaName);
                
                TableSchema.TableColumn colvarMediaType = new TableSchema.TableColumn(schema);
                colvarMediaType.ColumnName = "MediaTypeCode";
                colvarMediaType.DataType = DbType.Int32;
                colvarMediaType.MaxLength = 0;
                colvarMediaType.AutoIncrement = false;
                colvarMediaType.IsNullable = true;
                colvarMediaType.IsPrimaryKey = false;
                colvarMediaType.IsForeignKey = false;
                colvarMediaType.IsReadOnly = false;
                
                schema.Columns.Add(colvarMediaType);
                
                TableSchema.TableColumn colvarMediaTypeName = new TableSchema.TableColumn(schema);
                colvarMediaTypeName.ColumnName = "MediaTypeName";
                colvarMediaTypeName.DataType = DbType.String;
                colvarMediaTypeName.MaxLength = 50;
                colvarMediaTypeName.AutoIncrement = false;
                colvarMediaTypeName.IsNullable = true;
                colvarMediaTypeName.IsPrimaryKey = false;
                colvarMediaTypeName.IsForeignKey = false;
                colvarMediaTypeName.IsReadOnly = false;
                
                schema.Columns.Add(colvarMediaTypeName);
                
                TableSchema.TableColumn colvarTv = new TableSchema.TableColumn(schema);
                colvarTv.ColumnName = "TV";
                colvarTv.DataType = DbType.Boolean;
                colvarTv.MaxLength = 0;
                colvarTv.AutoIncrement = false;
                colvarTv.IsNullable = false;
                colvarTv.IsPrimaryKey = false;
                colvarTv.IsForeignKey = false;
                colvarTv.IsReadOnly = false;
                
                schema.Columns.Add(colvarTv);
                
                TableSchema.TableColumn colvarRd = new TableSchema.TableColumn(schema);
                colvarRd.ColumnName = "RD";
                colvarRd.DataType = DbType.Boolean;
                colvarRd.MaxLength = 0;
                colvarRd.AutoIncrement = false;
                colvarRd.IsNullable = false;
                colvarRd.IsPrimaryKey = false;
                colvarRd.IsForeignKey = false;
                colvarRd.IsReadOnly = false;
                
                schema.Columns.Add(colvarRd);
                
                TableSchema.TableColumn colvarCb = new TableSchema.TableColumn(schema);
                colvarCb.ColumnName = "CB";
                colvarCb.DataType = DbType.Boolean;
                colvarCb.MaxLength = 0;
                colvarCb.AutoIncrement = false;
                colvarCb.IsNullable = false;
                colvarCb.IsPrimaryKey = false;
                colvarCb.IsForeignKey = false;
                colvarCb.IsReadOnly = false;
                
                schema.Columns.Add(colvarCb);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["Adex"].AddSchema("vProgram",schema);
            }

        }

        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }

	    #endregion
	    
	    #region .ctors
	    public VProgram()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }

        public VProgram(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}

			MarkNew();
	    }

	    
	    public VProgram(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }

    	 
	    public VProgram(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }

        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("ProgramID")]
        public int ProgramID 
	    {
		    get
		    {
			    return GetColumnValue<int>("ProgramID");
		    }

            set 
		    {
			    SetColumnValue("ProgramID", value);
            }

        }

	      
        [XmlAttribute("ProgramCode")]
        public int ProgramCode 
	    {
		    get
		    {
			    return GetColumnValue<int>("ProgramCode");
		    }

            set 
		    {
			    SetColumnValue("ProgramCode", value);
            }

        }

	      
        [XmlAttribute("ProgramName")]
        public string ProgramName 
	    {
		    get
		    {
			    return GetColumnValue<string>("ProgramName");
		    }

            set 
		    {
			    SetColumnValue("ProgramName", value);
            }

        }

	      
        [XmlAttribute("MediaCode")]
        public int? MediaCode 
	    {
		    get
		    {
			    return GetColumnValue<int?>("MediaCode");
		    }

            set 
		    {
			    SetColumnValue("MediaCode", value);
            }

        }

	      
        [XmlAttribute("DateAdded")]
        public DateTime DateAdded 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("DateAdded");
		    }

            set 
		    {
			    SetColumnValue("DateAdded", value);
            }

        }

	      
        [XmlAttribute("DateModified")]
        public DateTime DateModified 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("DateModified");
		    }

            set 
		    {
			    SetColumnValue("DateModified", value);
            }

        }

	      
        [XmlAttribute("MediaName")]
        public string MediaName 
	    {
		    get
		    {
			    return GetColumnValue<string>("MediaName");
		    }

            set 
		    {
			    SetColumnValue("MediaName", value);
            }

        }

	      
        [XmlAttribute("MediaType")]
        public int? MediaType 
	    {
		    get
		    {
			    return GetColumnValue<int?>("MediaTypeCode");
		    }

            set 
		    {
			    SetColumnValue("MediaTypeCode", value);
            }

        }

	      
        [XmlAttribute("MediaTypeName")]
        public string MediaTypeName 
	    {
		    get
		    {
			    return GetColumnValue<string>("MediaTypeName");
		    }

            set 
		    {
			    SetColumnValue("MediaTypeName", value);
            }

        }

	      
        [XmlAttribute("Tv")]
        public bool Tv 
	    {
		    get
		    {
			    return GetColumnValue<bool>("TV");
		    }

            set 
		    {
			    SetColumnValue("TV", value);
            }

        }

	      
        [XmlAttribute("Rd")]
        public bool Rd 
	    {
		    get
		    {
			    return GetColumnValue<bool>("RD");
		    }

            set 
		    {
			    SetColumnValue("RD", value);
            }

        }

	      
        [XmlAttribute("Cb")]
        public bool Cb 
	    {
		    get
		    {
			    return GetColumnValue<bool>("CB");
		    }

            set 
		    {
			    SetColumnValue("CB", value);
            }

        }

	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string ProgramID = @"ProgramID";
            
            public static string ProgramCode = @"ProgramCode";
            
            public static string ProgramName = @"ProgramName";
            
            public static string MediaCode = @"MediaCode";
            
            public static string DateAdded = @"DateAdded";
            
            public static string DateModified = @"DateModified";
            
            public static string MediaName = @"MediaName";
            
            public static string MediaType = @"MediaTypeCode";
            
            public static string MediaTypeName = @"MediaTypeName";
            
            public static string Tv = @"TV";
            
            public static string Rd = @"RD";
            
            public static string Cb = @"CB";
            
	    }

	    #endregion
    }

}

